using System;
using System.Collections.Generic;
using MEA.AE_Data.Config;

namespace MEA.AE_Data
{
	public class ECU_Data : IECU_Data
	{
		private ushort hwRev;

		private bool isOnline;

		private List<EventLogEntry> eventRecEntries;

		private List<LogSignalLiveView> liveViewSignals;

		private List<ConfigLiveView.LiveViewVirtualSig> liveViewVirtualSignals;

		private DatLogCfg datlogCfg;

		private DTC[] dtcArray;

		private bool dtcReadOut;

		private bool iqaInitStep1Done;

		private bool iqaInitStep2Done;

		private int[,] statistics = new int[8, 8];

		private string[] iqaCylRead = new string[4];

		private string[] iqaCylWrite = new string[4];

		private string ecuHwVersionReadable = "not available";

		private ushort ecuHwVersionCode;

		private string ecuSerialNumber = "not available";

		private string ecuSwVersion = "not available";

		private string engineSerialNumber = "not available";

		private string engineType = "not available";

		private DateTime realTimeClock = DateTime.Now;

		private string realTimeClock_string = "not available";

		private string engineCountry;

		private string engineOEM;

		private string totalECUEngineControlTime = "not available";

		private double totalECUEngineControlTime_raw;

		private string totalECUPwrOnTime = "not available";

		private string totalEngineTime = "not available";

		public bool IsOnline
		{
			get
			{
				return isOnline;
			}
			set
			{
				isOnline = value;
			}
		}

		public List<EventLogEntry> EventRecEntries
		{
			get
			{
				return eventRecEntries;
			}
			set
			{
				eventRecEntries = value;
			}
		}

		public List<LogSignalLiveView> LiveViewSignals
		{
			get
			{
				return liveViewSignals;
			}
			set
			{
				liveViewSignals = value;
			}
		}

		public List<ConfigLiveView.LiveViewVirtualSig> LiveViewVirtualSignals
		{
			get
			{
				return liveViewVirtualSignals;
			}
			set
			{
				liveViewVirtualSignals = value;
			}
		}

		public DatLogCfg DatlogCfg
		{
			get
			{
				return datlogCfg;
			}
			set
			{
				datlogCfg = value;
			}
		}

		public DTC[] DTCArray
		{
			get
			{
				return dtcArray;
			}
			set
			{
				if (value != null)
				{
					dtcArray = new DTC[value.Length];
					for (int i = 0; i < value.Length; i++)
					{
						dtcArray[i] = value[i];
						for (int j = 0; j < 9; j++)
						{
							dtcArray[i].vals[j] = new DTC.Env(value[i].vals[j]);
						}
					}
				}
				else
				{
					dtcArray = value;
				}
			}
		}

		public bool DTCReadOut
		{
			get
			{
				return dtcReadOut;
			}
			set
			{
				dtcReadOut = value;
			}
		}

		public bool IQAInitStep1Done
		{
			get
			{
				return iqaInitStep1Done;
			}
			set
			{
				iqaInitStep1Done = value;
			}
		}

		public bool IQAInitStep2Done
		{
			get
			{
				return iqaInitStep2Done;
			}
			set
			{
				iqaInitStep2Done = value;
			}
		}

		public int[,] Statistics
		{
			get
			{
				return statistics;
			}
			set
			{
				statistics = value;
			}
		}

		public string[] IQACylRead
		{
			get
			{
				return iqaCylRead;
			}
			set
			{
				if (value.Length == 4)
				{
					iqaCylRead = value;
				}
			}
		}

		public string[] IQACylWrite
		{
			get
			{
				return iqaCylWrite;
			}
			set
			{
				iqaCylWrite = value;
			}
		}

		public DateTime RealTimeClock
		{
			get
			{
				return realTimeClock;
			}
			set
			{
				realTimeClock = value;
			}
		}

		public string RealTimeClock_string
		{
			get
			{
				return realTimeClock_string;
			}
			set
			{
				realTimeClock_string = value;
			}
		}

		public string EcuHwVersionReadable
		{
			get
			{
				string text = ecuHwVersionReadable;
				char[] trimChars = new char[1];
				return text.Trim(trimChars);
			}
			set
			{
				ecuHwVersionReadable = value;
			}
		}

		public ushort EcuHwVersionCode
		{
			get
			{
				return ecuHwVersionCode;
			}
			set
			{
				ushort num = value;
				ecuHwVersionCode = value;
				if (ConfigData.HwRevTable.ContainsKey(num))
				{
					ecuHwVersionReadable = (string)ConfigData.HwRevTable[num];
				}
				else
				{
					ecuHwVersionReadable = "unknown (" + ecuHwVersionCode.ToString("000") + ")";
				}
			}
		}

		public string EcuSerialNumber
		{
			get
			{
				string text = ecuSerialNumber;
				char[] trimChars = new char[1];
				return text.Trim(trimChars);
			}
			set
			{
				ecuSerialNumber = value;
			}
		}

		public string EcuSwVersion
		{
			get
			{
				string text = ecuSwVersion;
				char[] trimChars = new char[1];
				return text.Trim(trimChars);
			}
			set
			{
				ecuSwVersion = value;
			}
		}

		public string EngineSerialNumber
		{
			get
			{
				string text = engineSerialNumber;
				char[] trimChars = new char[1];
				return text.Trim(trimChars);
			}
			set
			{
				engineSerialNumber = value;
			}
		}

		public string EngineCountry
		{
			get
			{
				return engineCountry;
			}
			set
			{
				engineCountry = value;
			}
		}

		public string EngineOEM
		{
			get
			{
				return engineOEM;
			}
			set
			{
				engineOEM = value;
			}
		}

		public string EngineType
		{
			get
			{
				string text = engineType;
				char[] trimChars = new char[1];
				return text.Trim(trimChars);
			}
			set
			{
				engineType = value;
			}
		}

		public string TotalECUEngineControlTime
		{
			get
			{
				return totalECUEngineControlTime;
			}
			set
			{
				if (value != "")
				{
					totalECUEngineControlTime = value;
				}
				else
				{
					totalECUEngineControlTime = "not available";
				}
			}
		}

		public string TotalEngineTime
		{
			get
			{
				return totalEngineTime;
			}
			set
			{
				if (value != "")
				{
					totalEngineTime = value;
				}
				else
				{
					totalEngineTime = "not available";
				}
			}
		}

		public double TotalECUEngineControlTime_raw
		{
			get
			{
				return totalECUEngineControlTime_raw;
			}
			set
			{
				if (value > 0.0)
				{
					totalECUEngineControlTime_raw = value;
				}
			}
		}

		public string TotalECUPwrOnTime
		{
			get
			{
				return totalECUPwrOnTime;
			}
			set
			{
				if (value != null && value != "")
				{
					totalECUPwrOnTime = value;
				}
				else
				{
					totalECUPwrOnTime = "not available";
				}
			}
		}

		public ECU_Data()
		{
			eventRecEntries = new List<EventLogEntry>();
			liveViewSignals = new List<LogSignalLiveView>();
		}
	}
}
